<template>
	<view class="container">
		<!-- 筛选部分 -->
		<image src="../../static/images/screen_icon.png" alt="" class="screen" @click="popupShow=true" />
		<u-popup :show="popupShow" mode="top" @close="close" @open="open">
			<view :style="{'height':windowHeight}" style="position: relative;">
				<text class="typeTitle">状态</text>
				<u-icon @click="close" name="close" size="20" style="position: absolute;right: 32rpx;top: 62rpx;">
				</u-icon>
				<view class="screenBox">
					<view class="typeItem" :class="item == status?'typeBlue':''" v-for="(item, i) in statusList"
						:key="i" @click="changeStatus(item)">
						{{item}}
					</view>
				</view>
				<text class="typeTitle">类型</text>
				<view class="screenBox">
					<view class="typeItem" :class="item == type?'typeBlue':''" v-for="(item, i) in typeList" :key="i"
						@click="changeType(item)">
						{{item}}
					</view>
				</view>
				<view style="position: relative;">
					<text class="typeTitle">时间</text>
					<view style="position: absolute;right: 32rpx;top: 56rpx;" @click="show=true">
						<text style="color: #999999;font-size: 28rpx;">{{time?time:'请选择'}}</text>
						<image src="../../static/images/right.png" alt=""
							style="width: 38rpx;height: 38rpx;vertical-align: middle;">
					</view>
					<u-datetime-picker @cancel="closeTime" @confirm="submitTime" :show="show" v-model="date"
						mode="datetime">
					</u-datetime-picker>
				</view>
				<view class="screenBtns">
					<u-button class="custom-style" text="重置" plain @click="type='';status=''"></u-button>
					<u-button class="custom-style" text="确认" plain @click="confirm"></u-button>
				</view>
			</view>
		</u-popup>
		<!-- fixed按钮 -->
		<image src="../../static/images/noteEdit.png" class="noteEdit" alt="" @click="toPage('noteEdit')" />
		<view>
			<view v-for="(item,i) in noteList" :key="i" class="noteList" @click="toPage('noteDetail')">
				<text class="noteListTitle">{{item.time}}</text>
				<view class="notesDetail">
					<view class="notesTitle">
						<image v-if="item.type=='month'" src="../../static/images/monthNote.png" alt="" />
						<image v-else src="../../static/images/weekNote.png" alt="" />
						<text>{{item.title}}</text>
						<text>{{item.content}}</text>
						<text>全文</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				date: Number(new Date()),
				popupShow: false,
				noteList: [{
						time: '2022/03/01 20:30',
						title: '【教务处】学生助理',
						content: '来勤工助学这段日子我明白了责任的重要性，我们每一个做勤工助学的同学的心中都必须有一份强烈的责任感，因为，如果你没有一份强烈的责任感，你将无法在勤工助学立足。虽然工作有点无聊，乏味，但是这也正好可以锻炼我们的责任心，在勤工助学可以学到很多在课堂上都无法学到的东西',
						type: 'month'
					},
					{
						time: '2022/03/01 20:30',
						title: '【教务处】学生助理',
						content: '来勤工助学这段日子我明白了责任的重要性，我们每一个做勤工助学的同学的心中都必须有一份强烈的责任感，因为，如果你没有一份强烈的责任感，你将无法在勤工助学立足。虽然工作有点无聊，乏味。',
						type: 'week'
					},
				],
				windowHeight: "0",
				statusList: [
					'审批中', '已通过', '不通过'
				],
				status: '',
				typeList: [
					'月报', '日报'
				],
				type: '',
				time: '',
			}
		},
		onLoad() {
			uni.getSystemInfo({
				success: (res) => {
					this.windowHeight = (res.windowHeight + 44) + "px";
				}
			})
		},
		methods: {
			toPage(url) {
				uni.navigateTo({
					url: url
				})
			},
			changeStatus(item) {
				this.status = item
			},
			changeType(item) {
				this.type = item
			},
			confirm() {
				this.close()
			},
			close() {
				this.popupShow = false
			},
			closeTime() {
				this.show = false
			},
			submitTime() {
				this.$nextTick(() => {
					var date = new Date(this.date); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
					const Y = date.getFullYear() + '年';
					const M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '月';
					const D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + '日';
					const h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
					const m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes())
					this.time = Y + M + D + h + m
					this.closeTime()
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	page {
		background-color: #fafafa;
	}

	.container {
		position: relative;

		.screen {
			position: absolute;
			top: -66rpx;
			right: 32rpx;
			z-index: 1000;
			margin-left: 10rpx;
			vertical-align: middle;
			margin-bottom: 12rpx;
			margin-right: 18rpx;
			width: 40rpx;
			height: 44rpx;
		}

		.noteEdit {
			width: 100rpx;
			height: 100rpx;
			position: fixed;
			bottom: 96rpx;
			right: 32rpx;
		}

		.noteList {
			margin: 0 32rpx;



			.noteListTitle {
				font-size: 26rpx;
				font-weight: 400;
				color: #999999;
				line-height: 32rpx;
				display: flex;
				justify-content: center;
				padding: 16rpx 0;
			}

			.notesDetail {
				border-radius: 16rpx;
				padding: 40rpx 30rpx 24rpx;
				background-color: #fff;
				.notesTitle {
					image {
						width: 50rpx;
						height: 48rpx;
						vertical-align: middle;
					}

					text:nth-child(2) {
						font-size: 32rpx;
						font-weight: 500;
						color: #333333;
					}

					text:nth-child(3) {
						font-size: 28rpx;
						font-weight: 400;
						color: #999;
						margin-top: 32rpx;
						line-height: 44rpx;

						overflow: hidden;
						text-overflow: ellipsis;
						display: -webkit-box;
						-webkit-box-orient: vertical;
						-webkit-line-clamp: 5;
					}

					text:nth-child(4) {
						font-size: 26rpx;
						font-weight: 400;
						color: #2674FF;
						margin-top: 16rpx;
					}
				}
			}
		}
	}
</style>
